//找出只出现一次的元素
function single(nums) {
    var num = -1;
    for (var i = 0; i < nums.length; i++) {
        if (nums.indexOf(nums[i]) == nums.lastIndexOf(nums[i])) {
            num = nums[i];
        }
    }
    return num;
}
console.log(single([1, 2, 1, 2, 4, 2]));
//多维转一维
function flat(arr, k) {
    if (k === void 0) { k = 1; }
    var narr = [];
    arr.forEach(function (item) {
        if (Array.isArray(item) && k >= 1) {
            narr = narr.concat(flat(item, k - 1));
        }
        else {
            narr = narr.concat(item);
        }
    });
    return narr;
}
console.log(flat([1, [1, 2, 3, [1, 2, 3, 4, 5, 6]]]));
//一致字符串
var allowd = 'ab';
var words = ['ab', 'ac', 'abab'];
function fn1(words, allowd) {
    var obj = allowd.split('');
    var count = 0;
    words.forEach(function (item, index) {
        var items = item.split('');
        var c = 0;
        items.forEach(function (v, i) {
            if (v === obj[0] || v === obj[1]) {
                c++;
            }
        });
        if (item.length === c) {
            count++;
        }
    });
    return count;
}
console.log((fn1(words, allowd)));
